package com.study.rabbitmq;

import com.study.rabbitmq.config.ConsumerConfig;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;

import java.io.UnsupportedEncodingException;

public class ConsumerApp {
    public static void main(String[] args) throws UnsupportedEncodingException {
        AbstractApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfig.class);

        RabbitTemplate rabbitTemplate = context.getBean(RabbitTemplate.class);

        Message message = rabbitTemplate.receive("queue.anno");

        System.out.println(new String(message.getBody(),message.getMessageProperties().getContentEncoding()));

        context.close();
    }
}
